package day10;


import java.util.Scanner;

public class pta7_5有趣的括号 {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        SqStack<Character> sqStack = new SqStack<>(110);
        String str = sc.nextLine();
        char ch = ' ', ch1 = ' ';
        for (int i = 0;i < str.length();i++){
            ch = str.charAt(i);
            if (ch == '(' || ch == '{' || ch == '['){
                sqStack.push(ch);
            }
            if (!sqStack.isEmpty()){
                ch1 = sqStack.peek();
                if (ch == ')'){
                    if (ch1 == '(')
                        sqStack.pop();
                }
                 else if (ch == ']'){
                     if (ch1 == '[')
                         sqStack.pop();
                 }
                 else if (ch == '}'){
                     if (ch1 == '{')
                         sqStack.pop();
                }

            }

        }
        if (sqStack.isEmpty()){
            System.out.println("True");
        }
        else {
            System.out.println("False");
        }
    }
}
class SqStack<T>{
    private T[] stackElem;
    private int top;
    private int maxSize;

    public SqStack(int maxSize) {
        top = 0;
        this.maxSize = maxSize;
        stackElem = (T[]) new Object[maxSize];
    }

    public void clear() {
        top = 0;
    }

    public boolean isEmpty() {
        return top == 0;
    }

    public int length() {
        return top;
    }

    public T peek() {
        if (!isEmpty())
            return stackElem[top-1];
        else
            return null;
    }

    public void push(T x) throws Exception {
        if (top == maxSize)
            throw new Exception("栈已满");
        stackElem[top] = x;
        top ++;
    }

    public T pop() {
        if (isEmpty())
            return null;
        top --;
        return stackElem[top];
    }

    public void display() {
        if(top == 0){
            System.out.println("栈为空");
        }
        else {
            for (int i = top-1;i >= 0;i--){
                System.out.println(stackElem[i] + " ");
            }
        }
    }
}
